from fastapi import APIRouter, Path, Query, Body, Depends, HTTPException
from sqlalchemy import select, update, delete
from sqlalchemy.orm import Session

from ch04.db_main import get_session
from ch07.schemas import UserCreate

ch7 = APIRouter(prefix='/user', tags=['后端API'])


@ch7.get(path='/test1/', description='get请求测试')
def get_test(id: int, session: Session = Depends(get_session)):
    print(id)
    return {'msg': 'Ok'}


@ch7.post(path='/test2/', description='get请求测试')
def post_test(user: UserCreate, session: Session = Depends(get_session)):
    print(user.username, user.password)
    return user